﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="GetAjaxData_Diff_Type.aspx.cs" Inherits="ProjectStudy.GetAjaxData_Diff_Type" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="Scripts/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>
    <script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {
            //返回int型
            $("#btn1").click(function () {
                $.ajax({
                    type: "post",
                    url: "../Ajax/Ajax_ReturnDataType.ashx",
                    data: { "action": "getInt" },
                    dataType: "json",
                    success: function (data) {
                        alert(data);
                    }
                });
            });

            //返回float型
            $("#btn2").click(function () {
                $.ajax({
                    type: "post",
                    url: "../Ajax/Ajax_ReturnDataType.ashx",
                    data: { "action": "getFloat" },
                    dataType: "json",
                    success: function (data) {
                        alert(data);
                    }
                });
            });

            //返回double型
            $("#btn3").click(function () {
                $.ajax({
                    type: "post",
                    url: "../Ajax/Ajax_ReturnDataType.ashx",
                    data: { "action": "getDouble" },
                    dataType: "json",
                    success: function (data) {
                        alert(data);
                    }
                });
            });

            //返回string型
            $("#btn4").click(function () {
                $.ajax({
                    type: "post",
                    url: "../Ajax/Ajax_ReturnDataType.ashx",
                    data: { "action": "getString" },
                    dataType: "text",
                    success: function (data) {
                        alert(data);
                    }
                });
            });

            //返回bool型
            $("#btn5").click(function () {
                $.ajax({
                    type: "post",
                    url: "../Ajax/Ajax_ReturnDataType.ashx",
                    data: { "action": "getBool" },
                    dataType: "text",
                    success: function (data) {
                        alert(data);
                    }
                });
            });

            //返回list
            $("#btn6").click(function () {
                $.ajax({
                    type: "post",
                    url: "../Ajax/Ajax_ReturnDataType.ashx",
                    data: { "action": "getList" },
                    dataType: "json",
                    success: function (data) {
                        alert(data[0]);
                    }
                });
            });

            //返回dictionary型
            $("#btn7").click(function () {
                $.ajax({
                    type: "post",
                    url: "../Ajax/Ajax_ReturnDataType.ashx",
                    data: { "action": "getDictionary" },
                    dataType: "json",
                    success: function (data) {
                        alert(data["1"]);
                        alert(data["2"]);
                    }
                });
            });

            $("#btn8").click(function () {
                $.ajax({
                    type: "post",
                    url: "../Ajax/Ajax_ReturnDataType.ashx",
                    data: { "action": "getDataTable" },
                    dataType: "json",
                    success: function (data) {
                        $.each(data, function (index, item) {
                            if (index == 0) {
                                alert(item.ClassName);
                            }
                        });
                    }
                });
            });

        });  
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <input  type="button" id="btn1" value="从ajax获取int型数据"/>
    <br />
    <br />
    <input  type="button" id="btn2" value="从ajax获取float型数据"/>
    <br />
    <br />
    <input  type="button" id="btn3" value="从ajax获取double型数据"/>
    <br />
    <br />
    <input  type="button" id="btn4" value="从ajax获取string型数据"/>
    <br />
    <br />
    <input  type="button" id="btn5" value="从ajax获取bool型数据"/>
    <br />
    <br />
    <input  type="button" id="btn6" value="从ajax获取list型数据"/>
    <br />
    <br />
    <input  type="button" id="btn7" value="从ajax获取dictionary型数据"/>
    <br />
    <br />
    <input  type="button" id="btn8" value="从ajax获取datatable型数据"/>
    <br />
    <br />
    </div>
    </form>
</body>
</html>
